package task2;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class test3 {//双指针法
    static Scanner input=new Scanner(System.in);
    static ArrayList<Integer> list1=new ArrayList<>();
    static ArrayList<Integer> list2=new ArrayList<>();
    static HashSet<Integer> set=new HashSet<>();
    public static void main(String[] args) {//输入数据
        int num;
        int length1=input.nextInt();
        int length2=input.nextInt();

        for(int i=0;i<length1;i++){//list1
            num=input.nextInt();
            list1.add(num);
        }

        for(int i=0;i<length2;i++){//list2
            num=input.nextInt();
            list2.add(num);
        }

        System.out.println(computeNotExistNum());
    }
    private static int computeNotExistNum(){

        set.addAll(list1);
        set.addAll(list2);
        int repeat=(list1.size()+list2.size())- set.size();

        return list1.size()-repeat;
    }
}
